package org.cuatrovientos.struts.tulebox.example;



import java.util.Random;

import com.opensymphony.xwork2.ActionSupport;
/**
 * 
 * @author Dani
 *
 */
public class Dice extends ActionSupport {

	private int number=1;
	private int resultado=0;



	public int getNumber() {
		return number;
	}



	public void setNumber(int number) {
		this.number = number;
	}



	public int getResultado() {
		return resultado;
	}



	public void setResultado(int resultado) {
		this.resultado = resultado;
	}


/**
 * Returns a random number between 1 and the selected number
 */
	@Override
	public String execute()
	{
		
		Random r = new Random();
		resultado = r.nextInt(number)+1;

		return SUCCESS;
	}



	//		@Override
	//		public void validate() {
	//			if (number<1){
	//				addFieldError("number", "You must write a positive number here");
	//			}
	
}





